package com.baizhi;

import com.baizhi.service.ProductService;
import com.baizhi.service.impl.ProductServiceImpl;
import com.github.pagehelper.PageInfo;

public class ProductAction {
    private Sale sale;
    private ProductService ps=new ProductServiceImpl();
    private int where=1;
    private int pageIndex=1;
    private int pageSize=2;
    private  PageInfo page;
    private  int id=2;
    private int kucun;
    public String update(){
        int quantity=40;
        int quantity1 = sale.getQuantity();
        quantity=quantity1+quantity;
        sale.setQuantity(quantity);
        sale.setUserId(2);
        sale.setTotalPrice(sale.getPrice()*quantity);
        ps.updateProduct(sale,quantity);
        return "update";
    }
    public String page(){
       if (where==1){
           page = ps.page("order by saledate desc", pageIndex, pageSize);
           System.out.println(page);
           return "page";
       }
       if (where==2){
           page = ps.page("order by totalprice desc", pageIndex, pageSize);
           return "page";
       }
       return "page";
    }

    public String kucun(){
         kucun = ps.kucun(id);
        System.out.println(kucun);
         return "show";
    }

    public int getKucun() {
        return kucun;
    }

    public void setKucun(int kucun) {
        this.kucun = kucun;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public PageInfo getPage() {
        return page;
    }

    public void setPage(PageInfo page) {
        this.page = page;
    }

    public int getWhere() {
        return where;
    }

    public void setWhere(int where) {
        this.where = where;
    }

    public Sale getSale() {
        return sale;
    }

    public void setSale(Sale sale) {
        this.sale = sale;
    }
}
